package com.dream.fly.juststartserviceribbon.service;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

/**
 * Created by xsh10810
 * Time 2018/4/28 10:36
 */
@Service
public class HelloService {

	@Autowired
	private RestTemplate restTemplate;

	@HystrixCommand(fallbackMethod = "hiError")
	public String hiService(String name){
		return restTemplate.postForObject("http://just-start-eureka-client/hi?name={name}",null,String.class,name);
	}

	public String hiError(String name){
		return "hi,"+name+",sorry,error!";
	}
}
